package demo;

public class 实现接口类方法调用 {
    public static void main(String[] args) {
        int a = 2;
        achieve(new fn() {        //new匿名内部类
            @Override
            public int sum() {
                return a+a;
            }
        });
    }

    public static void achieve(fn f){
        int a = f.sum();
        System.out.println(a);
    }
}

interface fn{
    abstract int sum();
}